import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import HeaderNav from '../components/HeaderNav.vue'
import Person from '../components/PersonInfo.vue'
import Person2 from '../components/PersonInfo2.vue'
import Person3 from '../components/PersonInfo2.vue'
import FullPage from '../components/FullPage.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      children: [
        {
          path: '/person',
          name: 'person',
          component: Person
        },
      ]
    },
    
    {
      path: '/person2',
      name: 'person2',
      component: Person2
    },
    {
      path: '/person3',
      name: 'person3',
      component: Person3
    },
    {
      path: '/fullpage',
      name: 'fullpage',
      component: FullPage
    },

    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    }
  ],
  // 下滑动画配置
  scrollBehavior(to, from, savedPosition) {
    if (to.hash) {
      return {
        selector: to.hash
      }
    } else {
      return {
        x: 0,
        y: 0,
        behavior: 'smooth'
      }
    }
  }
})

export default router
